<%@ page contentType="text/html;charset=utf-8" isELIgnored="false" %>
<%@ include file="/head.jsp" %>
<html>
	<head>
		<title>Sunflower Bible Login</title>
		<style>
td {
  font-size:15px;
  background:#EFEFEF;
}
</style>
	</head>
	<body>
		<table style="position:absolute;left:400px;top:200px;height:130px;" bgcolor="#CCCCCC" width="380" border="0" align=center cellpadding="2" cellspacing="1">
			<tr>
          <td style="padding:3px 0;text-align:left;height:30px;font-size:20px;" valign="bottom" colspan="12" >登录</td>
      </tr>
			<tr><td style="width:30%;text-align:right;">用户名</td><td><input type="text" id="username" name="username" style="border:1px #CCC solid; height:25px;width:180px;" /></td></tr>
			<tr><td style="width:30%;text-align:right;">密码</td><td><input type="password" id="passwd" name="passwd" style="border:1px #CCC solid; height:25px;width:180px;" /></td></tr>			
			<tr>
          <td style="padding:3px 0;text-align:center;" valign="bottom" colspan="12" ><button style="width:60px;height:25px;" onclick="submitForm()">确定</button></td>
      </tr>
			</table>
	</body>
	<script>
		 function submitForm(){
		 	  var loginurl = "${ctx}/login.do";
		 	  var param = "action=login&username=" + $("#username").val() + "&pwd=" + $("#passwd").val();
		 	  $.ajax({
		 	  	  url: loginurl,
     	     type: "GET",
     	     cache:false,
     	     data:param,
     	     success:function(data, textStatus){
     	     	   if("success" == data ){
     	     	   	   window.location.href = "${ctx}/main.do";
     	     	   }else{
     	     	   	   alert("用户名或密码出错!");
     	     	   }     	     	   
     	     },
     	     error:function(XMLHttpRequest, textStatus, errorThrown){
     	     	   alert("后台运行出错，请重试!");
     	     }
		 	  });
		 }
	</script>
</html>